﻿using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using MicroApplication.Common.Input;
using MicroApplication.Common.Output;
using MicroApplication.Model.Business;
using MicroApplication.Service.Business.Driver;
using MicroApplication.Service.Business.Driver.Input;

namespace MicroApplication.Web.Controllers.Business
{
    /// <summary>
    /// 司机信息管理
    /// </summary>
    public class DriverController : BaseController
    {
        private readonly IDriverService _driverServices;

        public DriverController(IDriverService driverServices)
        {
            _driverServices = driverServices;
        }

        /// <summary>
        /// 查询单条司机信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IResponseOutput> Get(long id)
        {
            return await _driverServices.GetAsync(id);
        }

        /// <summary>
        /// 查询分页司机信息
        /// </summary>
        /// <param name="model">分页模型</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IResponseOutput> GetPage(PageInput<DriverEntity> model)
        {
            return await _driverServices.PageAsync(model);
        }

        /// <summary>
        /// 新增司机信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IResponseOutput> Add(DriverAddInput input)
        {
            return await _driverServices.AddAsync(input);
        }

        /// <summary>
        /// 修改司机信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<IResponseOutput> Update(DriverUpdateInput input)
        {
            return await _driverServices.UpdateAsync(input);
        }

        /// <summary>
        /// 删除司机信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<IResponseOutput> Delete(long id)
        {
            return await _driverServices.DeleteAsync(id);
        }
    }
}
